<!DOCTYPE html>
<html lang="en">
<title>HTMLSelectListElement Test: form submission</title>
<link rel="author" title="Ionel Popescu" href="mailto:iopopesc@microsoft.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<form id="form0">
  <selectlist name="s0" id="selectlist0">
    <option selected>one</option>
    <option>two</option>
    <option>three</option>
  </selectlist>
</form>

<form id="form1">
  <input type="text" name="i1" value="test">
  <selectlist id="selectlist1">
    <option selected>one</option>
    <option>two</option>
    <option>three</option>
  </selectlist>
</form>

<script>

test(() => {
  const form0 = document.getElementById("form0");
  const selectList0 = document.getElementById("selectlist0");
  assert_equals(selectList0.value, "one");

  const formData = new FormData(form0);
  let entries = 0;
  for (let entry of formData.entries()) {
    assert_equals(entry[0], "s0");
    assert_equals(entry[1], "one");
    entries++;
  }
  assert_equals(entries, 1);
}, "Test that HTMLSelectList.value is used for form submission");

test(() => {
  const form1 = document.getElementById("form1");
  const selectList1 = document.getElementById("selectlist1");
  assert_equals(selectList1.value, "one");

  const formData = new FormData(form1);
  let entries = 0;
  for (let entry of formData.entries()) {
    assert_equals(entry[0], "i1");
    assert_equals(entry[1], "test");
    entries++;
  }
  assert_equals(entries, 1);
}, "Test that HTMLSelectList.value is not used for form submission without name attribute");

</script>
